﻿using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using EasyXaf.ObjectSpaces.OData;
using System.ComponentModel;

namespace EasyXaf.Sample.Module.BusinessObjects;

[DomainComponent]
[Microsoft.OData.Client.EntitySet("Departments")]
public class Department : ODataObject<Guid>
{
    public string Name
    {
        get => GetPropertyValue<string>();
        set => SetPropertyValue(value);
    }

    [DataSourceProperty(nameof(CompanyDataSource))]
    public Company Company
    {
        get => GetPropertyValue<Company>();
        set => SetPropertyValue(value);
    }

    [Browsable(false)]
    [Microsoft.OData.Client.IgnoreClientProperty]
    public IList<Company> CompanyDataSource
    {
        get => ObjectSpace.GetObjectsQuery<Company>().Take(20).ToList();
    }

    public Department()
    {
        Id = Guid.NewGuid();
    }
}
